﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PersonalWebSite.Common;
using PersonalWebSite.Common.Google;
using PersonalWebSite.Models;

namespace PersonalWebSite.Controllers
{
    public class ActivityController : BaseController
    {
        //
        // GET: /Activity/

        public ActionResult Index(int pageIndex = 0)
        {
            return View(new ActivityViewModel { PageIndex = pageIndex });
        }

        public ActionResult PhotoAlbums()
        {
            return View();
        }

        public ActionResult Videos(int pageIndex = 0)
        {
            return View(new VideosViewModel { PageIndex = pageIndex });
        }

        public ActionResult Links()
        {
            return View();
        }

        public ActionResult PhotoAlbum(string id)
        {
            return View(new PhotoAlbumViewModel { AlbumId = id });
        }

        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult Activities(int pageIndex = 0)
        {
            return Json(GooglePlusManager.FetchActivityFeed(pageIndex), JsonRequestBehavior.AllowGet);
        }

        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult FetchPhotoAlbums()
        {
            return Json(GooglePicasaManager.FetchAlbumsFeed(), JsonRequestBehavior.AllowGet);
        }

        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult FetchPhotosForAlbum(string albumId)
        {
            return Json(GooglePicasaManager.FetchAlbumPhotosFeed(albumId), JsonRequestBehavior.AllowGet);
        }

        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult FetchVideos()
        {
            return Json(VideoManager.FetchVideos(), JsonRequestBehavior.AllowGet);
        }

        [CacheControl(HttpCacheability.NoCache), HttpGet]
        public JsonResult FetchLinks()
        {
            return Json(LinksManager.FetchLinks(), JsonRequestBehavior.AllowGet);
        }
    }
}
